Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access files as setuptools pkg_resource #2309

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

ajw-aws
Copy link

@ajw-aws ajw-aws commented May 25, 2020

from data/__init__.py:

with open("data/insecure.json") as __f:

That open is relative to your working directory, the reason it works for testing is that folder data is in the root of your package. The proper way to access this file is with pkg_resources from setuptools as a resource_filename.

@nrbgt
Copy link

nrbgt commented Jun 12, 2020

This looks great! Adding setuptools to install_requires in setup.py would be good, for completeness!

@ajw-aws
Copy link
Author

ajw-aws commented Jun 12, 2020

PR updated

This looks great! Adding setuptools to install_requires in setup.py would be good, for completeness!

setup.py Outdated
@@ -51,7 +51,7 @@
},
packages=['safety_db'],
license='Attribution-NonCommercial-ShareAlike 4.0 International',
install_requires=[],
install_requires=['install_requires'],
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

erm, setuptools

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...and 👍 for the quick response!

@pawamoy
Copy link

pawamoy commented Nov 18, 2020

Hello! Is there something I can help with to get this PR merged?

pawamoy referenced this pull request Nov 18, 2020
Not doing so causes nothing in the data directory to be included in the
distribution.
@lingrlongr
Copy link

Any reason why this has not merged yet?

@m-aciek
Copy link

m-aciek commented Dec 3, 2021

If I understand correctly stdlib's importlib.resources would be preferred over setuptools' pkg_resources, wouldn't they?

@bollwyvl
Copy link

bollwyvl commented Dec 3, 2021

stdlib's importlib.resources

Yep, wait a few more weeks on this until 3.6 is EOL and yeah, stdlib ftw!

efokschaner added a commit to efokschaner/safety-db that referenced this pull request Feb 4, 2022
This is a updated fix for pyupio#2308
and supersedes pyupio#2309

It uses importlib.resources which means dropping
support for python 3.6 and below
@efokschaner
Copy link

I've made a version of this PR which uses importlib.resources as suggested #2351

Let's get import safety_db working again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants